package org.ssp.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.ssp.dao.TaskDao;
import org.ssp.dao.TravelDao;
import org.ssp.dao.UserDao;
import org.ssp.impl.TaskImpl;
import org.ssp.impl.TravelImpl;
import org.ssp.impl.UserImpl;
import org.ssp.pojo.Assister;
import org.ssp.pojo.Task;
import org.ssp.pojo.Travel;
import org.ssp.pojo.User;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;

/**
 * 任务管理
 */
@WebServlet("/task")
public class TaskServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String method=request.getParameter("method");
		if(request.getSession().getAttribute("assist")==null){
			response.sendRedirect(request.getContextPath());
			return;
		}
		if("list".equals(method)){//1，分页显示总task列表
			System.out.println("task.....list.....");
			Assister assist=(Assister)request.getSession().getAttribute("assist");
			String assistid=assist.getId();
			/*	int page=Integer.valueOf(request.getParameter("page"));
			int rows=Integer.valueOf(request.getParameter("rows"));
			int offset=(page-1)*rows;
			int total=0;*/
			JSONObject json=new JSONObject();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			TaskDao taskd=new TaskImpl();
			ArrayList<Task> list=new ArrayList<Task>();
			if(assist.getType()==0){
				System.out.println("admin");
				list=taskd.findAll();
	/*			total=taskd.findAll();
	*/			

			}else{
				System.out.println("普通");
				list=taskd.findAllByAssist(assistid);
			}
			json.element("rows", JSONArray.fromObject(list,jsonConfig));
/*			json.element("total", total);
*/			System.out.println(json.toString());
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("mycreate".equals(method)){
			System.out.println("task.....mycreate...");
			Assister assist=(Assister)request.getSession().getAttribute("assist");
			String assistid=assist.getId();
			TaskDao taskd=new TaskImpl();
			ArrayList<Task> list=taskd.myCreate(assistid);
			JSONObject json=new JSONObject();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			json.element("success", true);
			json.element("rows", JSONArray.fromObject(list,jsonConfig));
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("finishlist".equals(method)){
			System.out.println("task....finishlist.....");
			Assister assist=(Assister)request.getSession().getAttribute("assist");
			String assistid=assist.getId();
			JSONObject json=new JSONObject();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			TaskDao taskd=new TaskImpl();
			ArrayList<Task> list=new ArrayList<Task>();
			if(assist.getType()==0){
				list=taskd.AllTaskFinish();
			}else{
				list=taskd.TaskFinishByAssistid(assistid);
			}
			json.element("rows", JSONArray.fromObject(list,jsonConfig));
           	System.out.println(json.toString());
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("unfinishlist".equals(method)){//我的任务，待处理任务
			System.out.println("task....unfinishlist.......");
			Assister assist=(Assister)request.getSession().getAttribute("assist");
			String assistid=assist.getId();
			TaskDao taskd=new TaskImpl();
			ArrayList<Task> list=taskd.unfinishByAssitid(assistid);
			JSONObject json=new JSONObject();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			json.element("success", true);
			json.element("rows", JSONArray.fromObject(list,jsonConfig));
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
			
		}else if("taskcount".equals(method)){
			System.out.println("task....taskcount.....");
			Assister assist=(Assister)request.getSession().getAttribute("assist");
			String assistid=assist.getId();
			TaskDao taskd=new TaskImpl();
			int count=taskd.unfinishCountByAssitid(assistid);
			JSONObject json=new JSONObject();
			json.element("success", true);
			json.element("count", count);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}
		else if("add".equals(method)){//2.添加任务
			System.out.println("task.....add....");
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			String due=request.getParameter("due");
			String responsibility=request.getParameter("responsibility");
			String joins=request.getParameter("joins");
			String assistid=((Assister)request.getSession().getAttribute("assist")).getId();
			ArrayList<String[]> list=new ArrayList<String[]>();//保存附件url+title
/*			ArrayList<String> joinlist=new ArrayList<String>();//保存joins参与人
*/		    //用j-spup从content中分解出内容和url链接
			Document doc=Jsoup.parse(content);//
			Elements links=doc.getElementsByTag("a");
			if(links!=null){
				for(Element link:links){
					String[] str=new String[2];
					str[0]=link.attr("href");
					System.out.println(str[0]);
					str[1]=link.text();
					System.out.println(str[1]);
					list.add(str);
	                link.remove();//移除a标签
				}
			}
		    //插入task任务
			Task task=new Task();
			task.setName(name);
			task.setContent(doc.text());
			task.setDue(new Date(due));
			task.setAssistid(assistid);
			task.setResponsibility(responsibility);
			TaskDao taskd=new TaskImpl();
			int id=taskd.addTask(task);
			System.out.println(id);
			//插入附件到task-attachmenturl
			for(String[] array:list){
				taskd.addAttachmentUrl(id, array[0], array[1]);
			}
			//插入参与人到task_joins
			String[] joinarray=joins.split(",");
            for(int i=0;i<joinarray.length;i++){
            	taskd.addJoin(id, joinarray[i]);
            }
            
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
		}else if("updatename".equals(method)){
			System.out.println("task......updatename....");
			String name=request.getParameter("name");
			String id=request.getParameter("id");
			TaskDao taskd=new TaskImpl();
			taskd.updateName(Integer.valueOf(id), name);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("updateresponsibility".equals(method)){
			System.out.println("task......updateresponsibility....");
			String responsibility=request.getParameter("responsibility");
			String id=request.getParameter("id");
			TaskDao taskd=new TaskImpl();
			taskd.updateResponsibility(Integer.valueOf(id), responsibility);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("updatedatime".equals(method)){
			System.out.println("task....updatedatime....");
			String due=request.getParameter("due");
			String id=request.getParameter("id");
			System.out.println("due"+new Date(due).toLocaleString());
			Task task=new Task();
			TaskDao taskd=new TaskImpl();
			taskd.updateDue(Integer.valueOf(id), new Date(due).toLocaleString());
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;

		}else if("addjoin".equals(method)){//添加参与人
			System.out.println("task...addjoin");
			String id=request.getParameter("id");
			String join=request.getParameter("join");
			TaskDao taskd=new TaskImpl();
			taskd.addJoin(Integer.valueOf(id),join);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;

		}else if("deletejoin".equals(method)){//删除参与人
			System.out.println("task....deletejoin.....");
			String assistid=request.getParameter("join");
			TaskDao taskd=new TaskImpl();
			taskd.deleteJoin(assistid);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("updatecontent".equals(method)){
			System.out.println("task....updatecontent");
			String id=request.getParameter("id");
			String content=request.getParameter("content");
			TaskDao taskd=new TaskImpl();
			taskd.updateContent(Integer.valueOf(id),content);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("addsub".equals(method)){
			System.out.println("task....addsub....");
			String parentid=request.getParameter("parentid");
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			String due=request.getParameter("due");
			String responsibility=request.getParameter("responsibility");
			String joins=request.getParameter("joins");
			String assistid=((Assister)request.getSession().getAttribute("assist")).getId();
			ArrayList<String[]> list=new ArrayList<String[]>();//保存附件url+title
/*			ArrayList<String> joinlist=new ArrayList<String>();//保存joins参与人
*/		    //用j-spup从content中分解出内容和url链接
			Document doc=Jsoup.parse(content);//
			Elements links=doc.getElementsByTag("a");
			if(links!=null){
				for(Element link:links){
					String[] str=new String[2];
					str[0]=link.attr("href");
					System.out.println(str[0]);
					str[1]=link.text();
					System.out.println(str[1]);
					list.add(str);
	                link.remove();//移除a标签
				}
			}
		    //插入task任务
			Task task=new Task();
			task.setName(name);
			task.setContent(doc.text());
			task.setDue(new Date(due));
			task.setAssistid(assistid);
			task.setResponsibility(responsibility);
			task.setParentid(Integer.valueOf(parentid));
			TaskDao taskd=new TaskImpl();
			int id=taskd.addsubTask(task);
			System.out.println(id);
			//插入附件到task-attachmenturl
			for(String[] array:list){
				taskd.addAttachmentUrl(id, array[0], array[1]);
			}
			//插入参与人到task_joins
			String[] joinarray=joins.split(",");
            for(int i=0;i<joinarray.length;i++){
            	taskd.addJoin(id, joinarray[i]);
            }
            
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
			
		}else if("rightlist".equals(method)){//返回子任务
			System.out.println("task.....rightlist.....");
			String id=request.getParameter("id");
			String parentid=request.getParameter("parentid");
			System.out.println("id...."+id);
			System.out.println("parentid..."+parentid);
			TaskDao taskd=new TaskImpl();
			ArrayList<Task> list=taskd.findSubTask(Integer.valueOf(id));//子任务列表
			Task taskparent=taskd.findById(Integer.valueOf(parentid));//父任务
			Task taskself=taskd.findById(Integer.valueOf(id));//任务本身
			ArrayList<Assister> listjoins=taskd.findJoinsById(Integer.valueOf(id));//参与人列表
            ArrayList<User> listuser=taskd.findUserById(Integer.valueOf(id));//关联的会员
		    ArrayList<String[]> listurl=taskd.findAttachment(Integer.valueOf(id));//任务附件
		    ArrayList<Travel> listtravel=taskd.findTravelById(Integer.valueOf(id));//关联的活动
		    
		    JSONObject json=new JSONObject();
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			json.element("success", true);
			json.element("list", JSONArray.fromObject(list,jsonConfig));
			json.element("taskparent",JSONObject.fromObject(taskparent, jsonConfig));
			json.element("taskself",JSONObject.fromObject(taskself, jsonConfig));
			json.element("joins", listjoins);
			json.element("listurl", listurl);
			json.element("listuser", JSONArray.fromObject(listuser,jsonConfig));
			json.element("listtravel", JSONArray.fromObject(listtravel,jsonConfig));
			
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			System.out.println(json.toString());
			return;
		}else if("deletetask".equals(method)){//4,删除任务
			System.out.println();
			String id=request.getParameter("id");
			TaskDao taskd=new TaskImpl();
			taskd.deleteTask(Integer.valueOf(id));
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("addusers".equals(method)){//关联会员
			System.out.println("task....addusers.....");
			String id=request.getParameter("id");
			String uid=request.getParameter("uid");
			System.out.println("id"+id);
			System.out.println("taskid");
			JSONObject json=new JSONObject();

			TaskDao taskd=new TaskImpl();
			if(taskd.addUser(Integer.valueOf(id), uid)>0){
				json.element("success", true);
				System.out.println("success");
			}else{
				json.element("success", false);
				System.out.println("fail");

			}
			System.out.println("panduan.............");
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("readuser".equals(method)){
			System.out.println("task....readuser.........");
			String uid=request.getParameter("uid");
			UserDao userd=new UserImpl();
			User user=userd.findById(uid);
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			JSONObject json=new JSONObject();
			json.element("success", true);
		    json.element("user", JSONObject.fromObject(user, jsonConfig));
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("deleteuser".equals(method)){
			System.out.println("task....deleteuser....");
			String taskid=request.getParameter("taskid");
			String uid=request.getParameter("uid");
			System.out.println(taskid);
			System.out.println(uid);
			TaskDao taskd=new TaskImpl();
			taskd.deleteUserTask(Integer.valueOf(taskid), uid);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("addtravel".equals(method)){//关联任务活动
			System.out.println("task.....addtravel.....");
			String taskid=request.getParameter("taskid");
			String travelid=request.getParameter("travelid");
			System.out.println(taskid);
			System.out.println(travelid);
			JSONObject json=new JSONObject();
			TaskDao taskd=new TaskImpl();
		 	int count=taskd.addTaskTravel(Integer.valueOf(taskid), Integer.valueOf(travelid));
		    if(count>0){
		    	json.element("success", true);
		    	System.out.println("success");
		    }else{
		    	json.element("success", false);
		    	System.out.println("fail");
		    }
		    PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("travelinfo".equals(method)){
			System.out.println("task.....travelinfo......");
			String id=request.getParameter("travelid");
			TravelDao td=new TravelImpl();
			Travel travel=td.findById(Integer.valueOf(id));
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			JSONObject json=new JSONObject();
			json.element("success", true);
		    json.element("travel", JSONObject.fromObject(travel, jsonConfig));
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("deletetravel".equals(method)){
			System.out.println("task....deletravel..........");
			String taskid=request.getParameter("taskid");
			String travelid=request.getParameter("travelid");
			System.out.println(taskid);
			System.out.println(travelid);
			TaskDao td=new TaskImpl();
			td.deleteTravel(Integer.valueOf(taskid), Integer.valueOf(travelid));
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("addattachment".equals(method)){
			System.out.println("task....addattachment....");
			String taskid=request.getParameter("taskid");
			String url=request.getParameter("url");
			String title=request.getParameter("title");
			System.out.println(taskid+"taskid");
			System.out.println(url+"url");
			TaskDao taskd=new TaskImpl();
			taskd.addAttachmentUrl(Integer.valueOf(taskid), url,title);
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;

		}else if("deleteattachment".equals(method)){
			System.out.println("task.....deleteattachment.....");
			String id=request.getParameter("id");
			TaskDao taskd=new TaskImpl();
			taskd.deleteAttachment(Integer.valueOf(id));
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("changestatus".equals(method)){
			System.out.println("task...changestatus....");
			String status=request.getParameter("status");
			String id=request.getParameter("id");
			TaskDao td=new TaskImpl();
			td.changeStatus(Integer.valueOf(status),Integer.valueOf(id));
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}
		
		/*else if("update".equals(method)){//3,修改任务
			System.out.println("task.....update....");
			String id=request.getParameter("id");
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			String assistid=request.getParameter("assistid");
			String due=request.getParameter("due");
			System.out.println("id="+id+";name="+name+";content="+content+";assistid="+assistid+";due="+due);
			Task task=new Task();
			task.setId(Integer.valueOf(id));
			task.setName(name);
			task.setContent(content);
			task.setAssistid(assistid);
			task.setDue(new Date(due));
			TaskDao taskd=new TaskImpl();
			taskd.update(task);
			JSONObject json=new JSONObject();
			json.element("success", true);
			response.setContentType("text/html;ccharset=utf-8");
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
			
		}else if("addsub".equals(method)){//5，添加子任务
			System.out.println("task.....addsub....");
			String name=request.getParameter("name");
			String content=request.getParameter("content");
			String assistid=request.getParameter("assistid");
			String due=request.getParameter("due");
			String parentid=request.getParameter("parentid");
			System.out.println(";name="+name+";content="+content+";assistid="+assistid+";due="+due+";parentid="+parentid);
			Task task=new Task();
			task.setName(name);
			task.setContent(content);
			task.setAssistid(assistid);
			task.setDue(new Date(due));
			task.setParentid(Integer.valueOf(parentid));
			TaskDao taskd=new TaskImpl();
			taskd.addSubTask(task);
			JSONObject json=new JSONObject();
			json.element("success", true);
			response.setContentType("text/html;ccharset=utf-8");
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
			
		}else if("changestatus".equals(method)){//7,改变任务的状态
			System.out.println("task....changestatus.....");
			String id=request.getParameter("id");
			String status=request.getParameter("status");
			String content=request.getParameter("content");
			System.out.println(id);
			System.out.println(status);
			TaskDao taskd=new TaskImpl();
			taskd.UpdateStatus(Integer.valueOf(id), Integer.valueOf(status));
			int count1=0;
			int count2=0;
			Task task1=taskd.findById(Integer.valueOf(id));
			if(task1.getId()!=task1.getParentid()){//说明是子任务
				ArrayList<Task> list1=taskd.findSub(task1.getParentid());
				for(Task task:list1){
					if(task.getId()!=task.getParentid()&&task.getStatus()==5){
						count1+=1;
					}
					if(task.getId()!=task.getParentid()&&task.getStatus()==3){
						count2+=1;
					}
				}
				System.out.println(count1);
				System.out.println(list1.size()-1);
				if(count1==list1.size()-1){
					taskd.UpdateStatus(task1.getParentid(), 5);
				}
				if(count2==list1.size()-1){
					taskd.UpdateStatus(task1.getParentid(), 3);
				}

			}
			if(content!=null){//有备份信息时需要
				taskd.UpdateBackinfo(Integer.valueOf(id),content);
			}
			ArrayList<Task> list=taskd.findSub(Integer.valueOf(id));
			if(list.size()>1){//有子任务时同时更新
				for(Task task:list){
					taskd.UpdateStatus(Integer.valueOf(task.getId()), Integer.valueOf(status));
				}
			}
			list=taskd.findSub(Integer.valueOf(id));
			System.out.println("成功");
			JSONObject json=new JSONObject();
			json.element("success", true);
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;
		}else if("assist-tasklist".equals(method)){//8,assist可见的任务列表
			System.out.println("task.....assist-tasklist.....");
			String assistid=request.getParameter("assistid");
			int page=Integer.valueOf(request.getParameter("page"));
			int rows=Integer.valueOf(request.getParameter("rows"));
			int offset=(page-1)*rows;
			int total=0;
			System.out.println(assistid);
			System.out.println(page);
			System.out.println(rows);
			TaskDao taskd=new TaskImpl();
			ArrayList<Task> list=taskd.findAssistTasks(Integer.valueOf(assistid), offset, rows);
			total=taskd.findAssistTasks(Integer.valueOf(assistid));
			JSONObject json=new JSONObject();
			json.element("total", total);
			JsonConfig jsonConfig = new JsonConfig();
			jsonConfig.registerJsonValueProcessor(java.util.Date.class,new JsonValueProcessor() {
			  private SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
			  public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
			    return  value == null ?"" : sd.format(value);
			  }
			  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
			    return null;
			  }
			});
			json.element("rows", JSONArray.fromObject(list,jsonConfig));
			System.out.println(json.toString());
			PrintWriter out=response.getWriter();
			out.write(json.toString());
			return;

		}*/
		else if("linkedlist".equals(method)){//7,相关联的任务列表
			
			
		}else{//9,超级管理员任务界面
			request.getRequestDispatcher("/WEB-INF/page/admin/task.jsp").forward(request, response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
